part of '../../repository.dart';

class _AppStorePurchasedItemDtoFactory {
  const _AppStorePurchasedItemDtoFactory._internal();

  static const _instance = _AppStorePurchasedItemDtoFactory._internal();

  factory _AppStorePurchasedItemDtoFactory() {
    return _instance;
  }

  _AppStorePurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kAppStorePurchasedItemTypeKey] as String;

    switch (type) {
      case _kAppStorePurchasedSubscriptionTypeValue:
        return _AppStorePurchasedSubscriptionDto.fromJson(json);
      case _kAppStoreOneTimePurchasedItemTypeValue:
        return _AppStoreOneTimePurchasedItemDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }
}
